/**
 * Created by jt on 2017/5/6.
 */
import "./index.less";
import "../../../unit/common/js/bootstrap_js/jquery.min.js";
import "../../../unit/common/js/bootstrap_js/ckeditor.js";
import "../../../unit/common/js/bootstrap_js/select2.min.js";
import "../../../unit/common/js/bootstrap_js/jquery.multi-select.js";
import "../../../unit/common/js/bootstrap_js/jquery.dataTables.js";
import "../../../unit/common/js/bootstrap_js/form-samples.js";
import "../../../unit/common/js/bootstrap_js/table-editable.js";
import "../../../unit/common/js/bootstrap_js/bootstrap-datetimepicker.js";
import "../../../unit/common/js/bootstrap_js/bootstrap-datetimepicker.zh-CN.js";
import "../../../unit/common/js/bootstrap_js/form-components.js";

jQuery(document).ready(function() {
    App.init();
    var token = sessionStorage.getItem('token');
    if (token == null || token =='') {
        location.href = HOST_FRT+'/logins/login.html';
    }
    jQuery('.logOut').attr('href','../logins/login.html');

    var projId = getArgs().id;

    jQuery.ajax({
            url: HOST_ADDR+'/cpmp/expt/view/'+projId,
            type: 'get',
            // data: JSON.stringify(data),
            dataType: 'json',
            contentType:"application/json",
        headers: {
            'access_token': token,'login_type':'ums'
        },
            success: function(resp){
                if (!resp.success) {
                    console.log(resp.msgCod+' '+resp.msgInf);
                    return;
                }
//			console.log(resp)
                jQuery('.exptNam').val(resp.data.exptNam);
                jQuery('.mobNbr').val(resp.data.mobNbr);
                jQuery('.exptTtl').val(resp.data.exptTtl);
                jQuery('.exptId').val(resp.data.exptId);
            },
            error:function(err){
                console.log(err);
            }
        });

    //提交
    jQuery('.subCheck').click(function () {
        let exptNam = jQuery('.exptNam').val();
        let mobNbr = jQuery('.mobNbr').val();
        let exptTtl = jQuery('.exptTtl').val();
        let exptId = jQuery('.exptId').val();
        if (exptNam =='') {
            alert('专家姓名不得为空！');
            return;
        }
        if (mobNbr =='') {
            alert('手机号不得为空！');
            return;
        }
        if (exptTtl =='') {
            alert('专家职称不得为空！');
            return;
        }

        let data = {
            "exptNam":exptNam,
            "mobNbr":mobNbr,
            "exptTtl":exptTtl,
            "exptId": exptId
        };
        console.log(data);

        jQuery.ajax({
            url: HOST_ADDR+'/cpmp/expt/mod',
            type: 'post',
            data: JSON.stringify(data),
            dataType: 'json',
            contentType:"application/json",
            headers: {
                'access_token': token,'login_type':'ums'
            },
            success: function(resp){
                if (!resp.success) {
                    alert(resp.msgCod+' '+resp.msgInf);
                    return;
                }
                console.log(resp);
                // //页面跳转到index
                alert('提交成功');
//						location.href = 'proj_list.html';
            },
            error:function(err){
                console.log(err);
            }
        });
    });

});